const BASE_URL = 'http://localhost:3000'
class service {
  request(url, data, method) {
    return new Promise((resolve, reject) => {
      wx.request({
        url: `${BASE_URL}${url}`,
        data,
        method,
        success: res => {
          resolve(res.data)
        },
        fail: reject
      })
    })
  }
  get({url, data}) {
    return this.request(url, data)
  }
  delete({url, data}) {
    return this.request(url, data,  method="DELETE")
  }
  post({url, data}) {
    return this.request(url, data,  method="POST")
  }
  put({url, data}) {
    return this.request(url, data,  method="PUT")
  }
}

export default new service()